package com.ukao.cashregister.eventbus;

import org.greenrobot.eventbus.EventBus;

/**
 * Created by herego on 2017/6/21.
 */

public class MembershipCardEvent<T> {
    private T data;
    private static Message mMembershipCardCmdType;



    public static enum Message {
        update,add,remove,delete,next,login,quit,fali,notFound,print,nfc_read,back_home
    }

    public MembershipCardEvent() {

    }

    public MembershipCardEvent(Message membershipCardCmdType, T data) {
        this.mMembershipCardCmdType = membershipCardCmdType;
        this.data = data;
    }

    public MembershipCardEvent(Message msg) {
        this.mMembershipCardCmdType = msg;
    }

    public static Message getMessage() {
        return mMembershipCardCmdType;
    }

    public <T> T getData() {
        return (T) data;
    }
    public static <T> void postHasData(Message msg, T data) {
        EventBus.getDefault().postSticky(new MembershipCardEvent(msg, data));
    }
    public static <T> void postNoData(Message msg) {
        EventBus.getDefault().post(new MembershipCardEvent(msg));
    }
}
